//
//  AddContactAPI.m
//  EMMApp
//
//  Created by 无常先生 on 2018/8/23.
//  Copyright © 2018年 YiXun. All rights reserved.
//

#import "AddContactAPI.h"
#define myUrlMethod @"addContactWay"
#define myUrlPath @"/appapi/addContactWay"
@implementation AddContactAPI
{
    NSString *_body;
}

- (instancetype)initWithTypeID:(NSString *)typeId date:(NSString *)date note:(NSString *)note  customerId:(NSString *)customerId{
    if (self = [super init]) {
        
        NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
        NSString *merchantId = [userdf objectForKey:@"merchantId"];
        NSString *userId = [userdf objectForKey:@"userNameId"];
        NSString *token = [userdf objectForKey:@"is_login"];
        NSString *projectCode = [userdf objectForKey:@"projectCode"];
        NSString *projectId = [userdf objectForKey:@"projectId"];
        
        NSMutableDictionary *params = [NSMutableDictionary dictionary];
        [params setValue:apiVersion forKey:@"version"];
        [params setValue:merchantId forKey:@"merchantId"];
        [params setValue:token forKey:@"token"];
        [params setValue:userId forKey:@"userId"];
        [params setValue:projectId forKey:@"projectId"];
        [params setValue:projectCode forKey:@"projectCode"];
        
        [params setValue:[IDTools devId2] forKey:@"terminalCode"];
        [params setValue:customerId forKey:@"customerId"];
        
        [params setValue:typeId forKey:@"ftContactWay1"];
        [params setValue:date forKey:@"ftContactTime1"];
        [params setValue:note forKey:@"ftContactContent1"];
        
        _body = [@{@"params" : params} JSONString];
    }
    return self;
}
#pragma mark - 父类继承拓展

- (NSString *)requestUrl
{
    return myUrlPath;
}

- (id)requestArgument
{
    return @{ @"body" : _body };
}

- (NSString *)methodString
{
    return myUrlMethod;
}

#pragma mark - 通用

- (id )resultData
{
    id myObj = [IDTools jsonStrToObjc:self.responseString method:myUrlMethod];
  
    return myObj;
}

- (BOOL)isSuccess
{
    NSString *str = [[self resultData] result];
    if ([NSString isStringEmpty:str] || ![str isEqualToString:@"1"]) {
        return NO;
    } else {
        return YES;
    }
}

@end
